# -*- coding: utf-8 -*-
# @Author : HaleShi
# @Time : 2023-07-10
# @File : 5_complete_password.py

import rsa
import base64


def encrypt_password(password):
    password_list = []
    for char in password:
        pub_key_str = '-----BEGIN PUBLIC KEY-----\nMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC9G4LU8LZtxApKhP81Usk7ze7obk8osQQcHhVdEfVoVIL3PTd2oIknWBBdIQz/r7HCVeZr6kMaESFc6dpmLime06JWyg902I0S+e8UnAaXhIQJso4wBVD4KtRKozCZ4XzFg8xK40/jO3rJA7WU7Tsn2qcr+MYyqLnN31umo3zZZwIDAQAB\n-----END PUBLIC KEY-----\n'
        key = rsa.PublicKey.load_pkcs1_openssl_pem(pub_key_str.encode('utf-8'))
        rsa_bytes = rsa.encrypt(char.encode(encoding='utf-8'), key)
        b64_bytes = base64.b64encode(rsa_bytes)
        password_list.append(b64_bytes.decode('utf-8'))
    return password_list

password = encrypt_password("123456qwer")
print(password)